package lesson;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //1.注册驱动
        Class.forName("com.mysql.jdbc.Driver");

        //2.获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql:///db1?useSSL=false","root","1234");

        //3.定义sql
        String sql = "update account set money = 999999 where id = 4";

        //4.获取执行sql的对象Statement
        Statement st = connection.createStatement();

        //5.执行sql
        int i = st.executeUpdate(sql);
        //6.处理结果
        System.out.println(i);
        //7.释放资源
        st.close();
        connection.close();



    }
}
